const app = getApp();
import grace from "../../../utils/grace.js";

grace.page({
  /**
   * 页面的初始数据
   */
  data: {
    accepts: [],
    school_name: '',
    class_id: 0,
    class_name: '',
    attendance_date: '',
  },
  onLoad() {
    let that = this;
    let d = new Date();
    that.$data = {
      'school_name': wx.getStorageSync('school_name'),
      'class_id': wx.getStorageSync('class_id'),
      'class_name': wx.getStorageSync('class_name'),
      'attendance_date': d.getFullYear() + '年' + (d.getMonth() + 1) + "月" + d.getDate() + '日'
    }

    wx.showLoading({
      title: '加载中...',
    })
    let url = app.globalData.api + '/api/v1.0/student/security/' + that.$data.class_id;
    that.$http.get(url, {token: wx.getStorageSync('token')}).then((res) => {
      if (res.data.code == 0) {
        that.$data.accepts = res.data.data;
      }
      wx.hideLoading();
    }).catch(err => {
      console.log(err.status, err.message);
    });
  }
})